package com.caiyouxi.boss.buser.controller;

import com.caiyouxi.boss.buser.model.SysLog;
import com.caiyouxi.boss.buser.service.SysLogService;
import com.caiyouxi.common.bean.ResData;
import com.caiyouxi.common.control.BaseController;
import com.caiyouxi.common.exception.ErrorCode;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/boss/syslog")
public class SysLogController extends BaseController{

    private Logger logger = Logger.getLogger(LoginController.class);

    @Autowired
    SysLogService sysLogService;

    @RequestMapping("/profile/log")
    public ResData get_log_info(HttpServletRequest request, HttpServletResponse response, @RequestBody  SysLog bean){

        logger.info("=============================== 用户日志详情 ================================");

        if(null == bean.getId()){
            return failed(ErrorCode.SYS_PARAMTER_MISSING.getCode(),ErrorCode.SYS_PARAMTER_MISSING.getMsg(),null);
        }
        return sysLogService.get_log_info(bean);
    }

    @RequestMapping("/list")
    public ResData get_log_list(HttpServletRequest request, HttpServletResponse response, @RequestBody  SysLog bean){

        logger.info("=============================== 日志列表 ================================");

        return sysLogService.get_log_list(bean);
    }
}
